import java.text.*;
import java.util.*;

public class Format {

    public static String format(long d, int width) {
        String s = Long.toString(d);
        String str = new String();
        for (int i = 0; i < width - s.length(); i++) {
            str += " ";
        }
        return (str + s);
    }

    public static String format(double x, int width, int precision) {
        StringBuffer strBuf = new StringBuffer();
        String str = new String();
        DecimalFormat decForm =
                (DecimalFormat) NumberFormat.getInstance(Locale.ITALIAN);
        FieldPosition intPos = new FieldPosition(DecimalFormat.INTEGER_FIELD);
        decForm.setMinimumFractionDigits(precision);
        decForm.setMaximumFractionDigits(precision);
        decForm.format(x, strBuf, intPos);
        for (int i = 0; i < width - strBuf.length(); i++) {
            str += " ";
        }
        return (str + strBuf);
    }

    public static String format(String s, int width, boolean alignLeft) {
        String str = new String();
        for (int i = 0; i < width - s.length(); i++) {
            str += " ";
        }
        if (alignLeft) {
            return (s + str);
        } else {
            return (str + s);
        }
    }
}
